<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Template Units For Numerical Applications</title>
<link href="TUNAstyles.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<style type="text/css">

.cabeza_cell {
  border-left: 1px solid #000000;
  border-right: 1px solid #000000;
  border-bottom: 1px solid #000000;
  border-top: 1px solid #000000;
  font-family: Arial,Helvetica,sans-serif;
  font-size: 11pt;
  background-color: #ffffff;
  font-weight: lighter;
  color: #000000;
  text-decoration: none;
}
</style>

</head><body>
<div>
<table align="center" width="640" border="0" cellspacing="2" cellpadding="5" class="border">
<tr>
 <td class="cabeza_cell"> 

  <font style="font-family: helvetica; color: #000000;" size=4>
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>TUNA</font> :
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>T</font>emplate
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>U</font>nits for
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>N</font>umerical 
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>A</font>pplications
 </font><br>
  
</td>
</tr>

<tr>
<td class="cabeza_cell">
 <span style="font-family: helvetica; color: #336699;">
 Documentation Ver 1.0.0 August 2011 by
 <a href="http://mmc.geofisica.unam.mx/luiggi">Luis M. de la Cruz</a> <br>
 <a href="http://mmc.geofisica.unam.mx"> GMMC </a> -
 <a href="http://www.geofisica.unam.mx/recnat/"> Depto. de Recursos Naturales </a> -
 <a href="http://www.geofisica.unam.mx"> Instituto de Geof&iacute;sica </a> -
 <a href="http://www.unam.mx"> UNAM </a><br>
 </span>
 </td>

</tr>

</table>
</div>
<br>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">Examples/02NonUniformMesh/complexmesh.cpp</div>  </div>
</div>
<div class="contents">
<a href="complexmesh_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;cmath&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;Meshes/StructuredMesh.hpp&quot;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;Meshes/NonUniform.hpp&quot;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;Utils/GNUplot.hpp&quot;</span>
<a name="l00018"></a>00018 <span class="keyword">using namespace </span>Tuna;
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="keyword">class </span>Sine {      
<a name="l00021"></a>00021   <span class="keywordtype">double</span> Amp;
<a name="l00022"></a>00022   <span class="keywordtype">double</span> Fre; 
<a name="l00023"></a>00023 <span class="keyword">public</span>:                                    
<a name="l00024"></a>00024   Sine(<span class="keywordtype">double</span> a, <span class="keywordtype">double</span> w) : Amp(a) { Fre = w * 0.5 * PI; }   
<a name="l00025"></a>00025   
<a name="l00026"></a>00026   <span class="keywordtype">double</span> operator() (<span class="keywordtype">double</span> epsi) {      
<a name="l00027"></a>00027     <span class="keywordflow">return</span> ( Amp * sin(Fre * epsi) ); 
<a name="l00028"></a>00028   }
<a name="l00029"></a>00029 };
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="keywordtype">int</span> main() 
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033     <span class="keywordtype">double</span> length_x, length_y;
<a name="l00034"></a>00034     <span class="keywordtype">int</span> num_nodes_x, num_nodes_y;
<a name="l00035"></a>00035     <span class="keywordtype">double</span> amplitude1, frequency1;
<a name="l00036"></a>00036     <span class="keywordtype">double</span> amplitude2, frequency2;
<a name="l00037"></a>00037     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Lenght x = &quot;</span>;
<a name="l00038"></a>00038     std::cin &gt;&gt; length_x;
<a name="l00039"></a>00039     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Lenght y = &quot;</span>;
<a name="l00040"></a>00040     std::cin &gt;&gt; length_y;
<a name="l00041"></a>00041     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Num of nodes x = &quot;</span>;
<a name="l00042"></a>00042     std::cin &gt;&gt; num_nodes_x;
<a name="l00043"></a>00043     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Num of nodes y = &quot;</span>;
<a name="l00044"></a>00044     std::cin &gt;&gt; num_nodes_y;
<a name="l00045"></a>00045     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Amplitude 1 = &quot;</span>;
<a name="l00046"></a>00046     std::cin &gt;&gt; amplitude1;
<a name="l00047"></a>00047     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Frequency 1 =&quot;</span>;
<a name="l00048"></a>00048     std::cin &gt;&gt; frequency1;
<a name="l00049"></a>00049     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Amplitude 2 = &quot;</span>;
<a name="l00050"></a>00050     std::cin &gt;&gt; amplitude2;
<a name="l00051"></a>00051     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Frequency 2 =&quot;</span>;
<a name="l00052"></a>00052     std::cin &gt;&gt; frequency2;
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="comment">// Reading data from the input file</span>
<a name="l00055"></a>00055 <span class="comment">/*</span>
<a name="l00056"></a>00056 <span class="comment">    std::ifstream input_cin (&quot;input&quot;); </span>
<a name="l00057"></a>00057 <span class="comment">    input_cin &gt;&gt; length_x;</span>
<a name="l00058"></a>00058 <span class="comment">    input_cin &gt;&gt; length_y;</span>
<a name="l00059"></a>00059 <span class="comment">    input_cin &gt;&gt; length_z;</span>
<a name="l00060"></a>00060 <span class="comment">    input_cin &gt;&gt; num_nodes_x; </span>
<a name="l00061"></a>00061 <span class="comment">    input_cin &gt;&gt; num_nodes_y; </span>
<a name="l00062"></a>00062 <span class="comment">    input_cin &gt;&gt; num_nodes_z; </span>
<a name="l00063"></a>00063 <span class="comment">    input_cin &gt;&gt; lambda;</span>
<a name="l00064"></a>00064 <span class="comment">    input_cin.close();</span>
<a name="l00065"></a>00065 <span class="comment">*/</span>
<a name="l00066"></a>00066     <a class="code" href="classTuna_1_1StructuredMesh.html" title="General structured meshes on rectangular domains.">StructuredMesh&lt;NonUniform&lt;double, 2&gt;</a> &gt; mesh_2D_C(length_x, num_nodes_x,
<a name="l00067"></a>00067                                                      length_y, num_nodes_y);
<a name="l00068"></a>00068 
<a name="l00069"></a>00069     mesh_2D_C.calcPoints(X, Sine(amplitude1, frequency1));
<a name="l00070"></a>00070     mesh_2D_C.calcPoints(Y, Sine(amplitude2, frequency2));
<a name="l00071"></a>00071     mesh_2D_C.print();
<a name="l00072"></a>00072     mesh_2D_C.writeToFile(<span class="stringliteral">&quot;./Data/mesh2DC&quot;</span>);
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 <span class="preprocessor">#ifdef WITH_GNUPLOT</span>
<a name="l00075"></a>00075 <span class="preprocessor"></span>    GNUplot plotter;
<a name="l00076"></a>00076     plotter(<span class="stringliteral">&quot;set view 0,0&quot;</span>);
<a name="l00077"></a>00077     plotter(<span class="stringliteral">&quot;splot \&quot;./Data/mesh2DC\&quot; w lp pt 7&quot;</span>);
<a name="l00078"></a>00078     std::cout &lt;&lt; <span class="stringliteral">&quot;\n &gt;---&gt; Press &lt;1&gt; and then &lt;enter&gt; to continue \n&quot;</span>;
<a name="l00079"></a>00079     <span class="keywordtype">int</span> pause; std::cin &gt;&gt; pause;
<a name="l00080"></a>00080 <span class="preprocessor">#endif</span>
<a name="l00081"></a>00081 <span class="preprocessor"></span>  
<a name="l00082"></a>00082     <span class="keywordflow">return</span> 0;
<a name="l00083"></a>00083 }
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr size="1">
<div align="center">
Last modification: Sun Aug 28 09:57:21 CDT 2011
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&copy; 2011 LMCS-UNAM
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Generated by <a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="top" border="0" height="25"></a> 1.6.1 </div>

